//========================================
//Player Class
//========================================
//Rob Cavanaugh	Basic Class strucrure
//				AI
//Kevin Henry		Directsound
//Created:  02/15/2008
//Last Modified: 02/04/2009
//========================================
#pragma once
#include "GameObject.h"
#include "BaseEntity.h"
#include "EntityManager.h"
#include "Camera.h"
#include "PlayerOwnedState.h"
#include "StateMachine.h"
#include "Projectile3D.h"
#include "DXConsole.h"

// forward declares
class Model;
class Camera;
class EnergyBall;
struct Telegram;

class Player : public BaseEntity
{
public:

	Player(int);
	~Player();

	// enumeration controlling the direction 
	enum { P_FORWARD=0, 
		   P_BACKWARD=1, 
		   P_LEFT=2, 
		   P_RIGHT=3, 
		   P_STRAFE_LEFT=4, 
		   P_STRAFE_RIGHT=5};

	bool  HandleMessage(const Telegram& msg);

	void move(int direction, float anim_rate);
	void PlayerInput();
    bool create(LPDIRECT3DDEVICE9 device, std::string modelName);
    void render(LPDIRECT3DDEVICE9 device);

	void vectorUpdate(float);
	void perpVectorUpdate(float posit);

	void update(float);
	float getRadius(){return m_radius;}
	float getMeleeRad(){return m_melee;}
	void setEnergy(int energy) {m_energy -= energy;}
	void chargeEnergy();
	void setOK(int timeok);
	bool isBallOn();
	bool nukeOn();
	bool nukeCreate();
	void EraseBall();
	void Nuke();
	void combat1();
	void combat2();
	void combat3();
	void combat4();
	bool death();

	D3DXVECTOR3 getEballPos();
	float getEballRad();
	
	D3DXVECTOR3 getENukePos();
	float getENukeRad();

	void updatePlayerFSM();

	StateMachine<Player>*	getFSM()const{return m_PlayerState;}
	
	void loadSounds();
	bool checkSounds();
	void releaseSounds();

private:

	bool m_release;
	bool m_pBall;
	bool m_expand;
	float m_radius;
	float m_melee;
	int   m_ok;

	DXConsole	   m_DXNOVA;
	DXConsole	   m_DXNOVA2;
	DXConsole      m_DXNOVA3;
	DXConsole      m_DXNOVA4;

	Camera         *m_camera;
	EnergyBall	   *m_eBall;
	EnergyBall	   *m_eBall2;

	float			m_bscale;

	// for HUD and win/loss conditions
	int				m_heath;
	int				m_energy;
	StateMachine<Player>*	m_PlayerState;
	//Directsound
	LPDIRECTSOUNDBUFFER DSBuffer;
	LPDIRECTSOUNDBUFFER DSBuffer2;
	LPDIRECTSOUNDBUFFER DSBuffer3;
	LPDIRECTSOUNDBUFFER DSBuffer4;
};
